package com.yowasa.xiuxian.engine.battle.strategy.drop.wood;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name="七步毒")
@Order(1003)
@Component
public class QiBuDu extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;
    @Override
    public ElementEnum getElement() {
        return ElementEnum.WOOD;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int atk = first.getBattleInfo().getSpell();
        int def = second.getBattleInfo().getRes();
        int dmg = battleHelper.calSpell(atk, def);
        battleHelper.autoAction(this, first, second, content, dmg, "七步毒");
        BuffContent buff = second.getBuff().get("七步毒");
        if (buff == null) {
            BuffContent buffContent = new BuffContent();
            buffContent.setDuration(5);
            buffContent.setNum(1);
            buffContent.setPositive(false);
            second.getBuff().put("七步毒", buffContent);
        }else {
            buff.setDuration(5);
            int num=buff.getNum() + 1;
            buff.setNum(num);
        }
    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("木") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用七步毒必须具有木灵根");
        }
    }
    @Override
    public String limitDesc() {
        return "具有木灵根";
    }

    @Override
    public String desc() {
        return "造成1.0倍术法伤害的同时,为对方施加一层七步毒素,中毒者在回合开始时受到基于毒素层数*移动速度*10%的免疫伤害";
    }
}
